package com.gupaoedu.spring.pattern.proxy.custom;

import com.gupaoedu.spring.pattern.proxy.staticed.Person;

import javax.jnlp.PersistenceService;
import java.lang.reflect.Method;

public class CustomMeiPo implements GPInvocationHandler{


    private Person target;

    public Object getInstance (Person target ) throws Exception{

        this.target = target;

        Class<?> clazz = target.getClass();

        return GPProxy.newProxyInstance(new GPClassLoader(),clazz.getInterfaces() ,this);
    }


    public Object invoke(Object proxy, Method method, Object[] obj) throws Throwable {


        System.out.println("我是媒婆：我要给你找对象，现在已经拿到你的需求");
        System.out.println("开始物色");

        method.invoke(this.target,obj);

        System.out.println("如果合适的话，就准备办事");


        return null;
    }
}
